package dp;

import java.util.Arrays;
import java.util.Scanner;

public class 跳跃 {

    //可以走的方向
    public static int next[][] = {
            {0, 1}, {1, 0},
            {0, 2}, {2, 0},
            {0, 3}, {3, 0},
            {1, 1}, {1, 2},
            {2, 1}
    };
    static int n;
    static int m;
    static int sum = -0x3f3f3f3f;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        m = scanner.nextInt();

        int[][] map = new int[n + 1][m + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                map[i][j] = scanner.nextInt();
            }
        }
        dfs(1, 1, 0, map);
//        print(map);
        System.out.println(sum);
    }

    public static void dfs(int x, int y, int step, int[][] map) {
        step += map[x][y];
        if (x == n && y == m) {
            sum = Math.max(sum, step);
            return;
        }
        for (int i = 0; i < 9; i++) {
            int tx = x + next[i][0];
            int ty = y + next[i][1];
            if (tx <= n && ty <= m) {
                dfs(tx, ty, step, map);
            }
        }

    }

    private static void print(int[][] map) {
        System.out.println("====");
        for (int[] line : map) {
            System.out.println(Arrays.toString(line));
        }
        System.out.println("====");
    }

}
